<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>6.10</title>
	
	</head>
	<style>
		#app {
			width: 600px;
			margin: 40px auto;
			text-align: center;
		}
	</style>
	<script src="js/vue.js"></script>
	<body>
		<div id="app">
			<h2>当前计数器的值为: {{num}}</h2>
			<counter v-on:counter-add="num++"></counter>
		</div>
	</body>
	<script>
		Vue.component('counter',{
			template: '<button @click="add">计数器</button>',
			methods: {
				add: function(){
					this.$emit('counter-add')
				}
			}
		})
		let vm = new Vue ({
			el: '#app',
			data: {
				num: 0
			},
			methods: {
				handleAdd: function(){
					this.num++
				}
			}
		})
	</script>
</html>